import * as React from 'react'
import { Layout,Login } from "../components";
import { Route, Redirect,useHistory } from "react-router-dom";
import { useAppSelector } from '../hooks';
export default ()=>{
    const h=useHistory()
    const isLogin=useAppSelector(store=>store.user.token)
    console.log(isLogin);
    if(!isLogin) h.replace('/login')
    return(
        <>
            {
                isLogin ?<Route path='/' component={Layout}/> : <Route path='/login' component={Login}
                />
            }
            {/* <Redirect from='/*' to='/login' /> */}
        </>
    )
}